package com.shop.cereshop.commons.enums;

import java.util.Objects;

public enum PaymentModeEnum {
    // 支付方式 1-微信 2-支付宝 3-钱包余额 4-银行卡 5-其他
    WX_PAY(1, "微信"),
    ZFB_PAY(2, "支付宝"),
    WALLET_PAY(3, "钱包余额"),
    BANK_CARD_PAY(4, "银行卡"),
    OTHER_PAY(5, "其他"),


    ;

    private Integer code;
    private String msg;

    private PaymentModeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        PaymentModeEnum[] arr = PaymentModeEnum.values();
        for (int i = 0; i < arr.length; i++) {
            if (code.equals(arr[i].getCode())) {
                return arr[i].getMsg();
            }
        }
        return "";
    }
}
